#pragma once
#include "boost\bind.hpp"
#include "boost\asio.hpp"
#include "boost\thread.hpp"
#include "boost\lexical_cast.hpp"

using namespace boost;
using namespace std;
class io_service_pool : public boost::noncopyable
{
public:
	explicit io_service_pool(size_t	pool_size);
	~io_service_pool();

	void start();

	void join();

	void stop();

	asio::io_service& get_io_service();

private:
	typedef boost::shared_ptr<boost::asio::io_service> io_service_sptr;
	typedef boost::shared_ptr<boost::asio::io_service::work> work_sptr;
	typedef boost::shared_ptr<boost::thread> thread_sptr;
	
	mutex							m_mutex;

	vector<io_service_sptr>			m_io_services;
	vector<work_sptr>				m_work;
	vector<thread_sptr>				m_threads;
	size_t							m_next_io_service;
};

